home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / Technical Documentation / develop / develop Issue 24 / develop Issue 24 code / Scriptable Database 1.0a15 / Foundation / ComparisonOperand.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  5.5 KB  |  140 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        ComparisonOperand.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Andy Nicholas, Greg Anderson, Chris Bingham, John Rohrlich, Max McFarland, Paul Ossenbruggen, Mike Kobb
  7.  
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.          <3>     9/26/95    pco        
  11.  
  12. */
  13.  
  14.  
  15. #ifndef __COMPARISONOPERAND__
  16. #define __COMPARISONOPERAND__
  17.  
  18. //
  19. // For declaration of TDescriptor
  20. //
  21. #include "MoreAEM.h"
  22.  
  23. class TAbstractScriptableObject;
  24. class TAbstractObjectSpecifier;
  25. class TAETransaction;
  26.  
  27. enum ComparitorType
  28.     {
  29.     kAbstractComparitor = 0,
  30.     kLiteralComparitor,
  31.     kSimplePropertyComparitor,
  32.     kCompoundPropertyComparitor
  33.     };
  34.  
  35. //========================================================================================
  36. //    CLASS TComparisonOperand
  37. //
  38. // Can be either literal data or an object specifier;
  39. // if it is an object specifier, then it can either be
  40. // a complete specifier (root object is the null container)
  41. // or it can be a specifier relative to the object being
  42. // examined (in a whose clause resolution).
  43. //========================================================================================
  44.  
  45. class TComparisonOperand
  46.     {
  47. public:
  48.     TComparisonOperand();
  49.     virtual ~TComparisonOperand();
  50.     
  51.     //
  52.     // A comparison operand knows what the best type of
  53.     // data is for it to return, should it be compared
  54.     // with some other operand, and it also knows what
  55.     // data types it can return.  Of course it must be
  56.     // able to return said data.
  57.     //
  58.     virtual DescType                    BestType(const TAETransaction& t, TAbstractScriptableObject* objectBeingExamined = nil) const = 0;
  59.     virtual Boolean                        CanReturnDataOfType(const TAETransaction& t, DescType desiredType, TAbstractScriptableObject* objectBeingExamined = nil) const = 0;
  60.     virtual TDescriptor                    GetData(const TAETransaction& t, DescType requestedType, TAbstractScriptableObject* objectBeingExamined = nil) const = 0;
  61.     
  62.     //
  63.     // A comparison operand may return either a reference
  64.     // to its data, or a copy of said data.  Only the
  65.     // comparison operand knows for sure, so call DisposeOperandData
  66.     // when done with the operand's data.
  67.     //
  68.     virtual void                        DisposeOperandData(TDescriptor operandData) const;
  69.     
  70.     //
  71.     // Compare two operands:
  72.     //
  73.     virtual Boolean                        Compare(const TAETransaction& t, DescType comparisonOperator, const TComparisonOperand& compareWith, TAbstractScriptableObject* objectBeingExamined = nil) const;
  74.     virtual Boolean                        Compare(const TAETransaction& t, DescType comparisonOperator, const DescType dataTypeToUse, TDescriptor otherOperandData, TAbstractScriptableObject* objectBeingExamined = nil) const;
  75.  
  76.     //
  77.     // Describe the data that is being compared
  78.     //
  79.     virtual TDescriptor                    SpecifierForOperand() = 0;
  80.     virtual ComparitorType                ComparisonOperandType() const;
  81.     virtual DescType                    PropertyToCompare() const;
  82.     };
  83.  
  84. //========================================================================================
  85. //    CLASS TConstantComparisonOperand
  86. //========================================================================================
  87.  
  88. class TConstantComparisonOperand : public TComparisonOperand
  89.     {
  90. private:
  91.     TDescriptor                            fConstantData;
  92.     Boolean                                fDataOwned;
  93.         
  94. public:
  95.     TConstantComparisonOperand(TDescriptor constantData, Boolean passOwnershipOfData = true);
  96.     ~TConstantComparisonOperand();
  97.     
  98.     virtual DescType                    BestType(const TAETransaction& t, TAbstractScriptableObject* objectBeingExamined = nil) const;
  99.     virtual Boolean                        CanReturnDataOfType(const TAETransaction& t, DescType desiredType, TAbstractScriptableObject* objectBeingExamined = nil) const;
  100.     virtual TDescriptor                    GetData(const TAETransaction& t, DescType requestedType, TAbstractScriptableObject* objectBeingExamined = nil) const;
  101.     virtual TDescriptor                    SpecifierForOperand();
  102.     virtual ComparitorType                ComparisonOperandType() const;
  103.     };
  104.  
  105. //========================================================================================
  106. //    CLASS TPropertyComparisonOperand
  107. //========================================================================================
  108.  
  109. class TPropertyComparisonOperand : public TComparisonOperand
  110.     {
  111. private:
  112.     DescType                            fPropertyToCompare;
  113.     TAbstractObjectSpecifier*            fRelativeSpecifier;
  114.     Boolean                                fIsRelativeToObjectBeingExamined;
  115.     
  116.     TDescriptor                            fCachedData;
  117.     DescType                            fCachedType;
  118.     TAbstractScriptableObject*            fObjectBeingExaminedForDataCache;
  119.     
  120.     TAbstractScriptableObject*            fCachedResolvedObject;
  121.     TAbstractScriptableObject*            fObjectBeingExaminedForResolveCache;
  122.  
  123. public:
  124.     TPropertyComparisonOperand(DescType propertyToCompare, TAbstractObjectSpecifier* relativeSpecifier, Boolean fIsRelativeToObjectBeingExamined);
  125.     virtual ~TPropertyComparisonOperand();
  126.  
  127.     TAbstractScriptableObject*            ResolveObjectBeingExamined(const TAETransaction& t, TAbstractScriptableObject* objectBeingExamined) const;
  128.     
  129.     virtual DescType                    BestType(const TAETransaction& t, TAbstractScriptableObject* objectBeingExamined = nil) const;
  130.     virtual Boolean                        CanReturnDataOfType(const TAETransaction& t, DescType desiredType, TAbstractScriptableObject* objectBeingExamined = nil) const;
  131.     virtual TDescriptor                    GetData(const TAETransaction& t, DescType requestedType, TAbstractScriptableObject* objectBeingExamined = nil) const;
  132.     virtual Boolean                        Compare(const TAETransaction& t, DescType comparisonOperator, const DescType dataTypeToUse, TDescriptor otherOperandData, TAbstractScriptableObject* objectBeingExamined = nil) const;
  133.     virtual TDescriptor                    SpecifierForOperand();
  134.     virtual ComparitorType                ComparisonOperandType() const;
  135.     virtual DescType                    PropertyToCompare() const;
  136.     };
  137.  
  138.  
  139. #endif
  140.